home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Idle / Repeater.cp < prev    next >
Text File  |  1997-06-28  |  619b  |  41 lines

  1. // Repeater.cp
  2.  
  3. #ifndef Repeater_h
  4. #include "Repeater.h"
  5. #endif
  6.  
  7. Repeater::Repeater( const Method& method, bool startEnabled )
  8.   : Enableable( startEnabled ),
  9.      repeat( this, &Repeater::Repeat ),
  10.      inProgress( false ),
  11.      toRepeat( method )
  12.   {
  13.     if ( startEnabled )
  14.         repeat.Schedule();
  15.   }
  16.  
  17. void Repeater::BeEnabled()
  18.   {
  19.     if ( !inProgress )
  20.         repeat.Schedule();
  21.   }
  22.  
  23. void Repeater::BeDisabled()
  24.   {
  25.     if ( !inProgress )
  26.         repeat.Cancel();
  27.   }
  28.  
  29. void Repeater::Repeat()
  30.   {
  31.     Assert( !inProgress );
  32.     Assert( Enabled() );
  33.     
  34.     inProgress = true;
  35.     toRepeat();
  36.     inProgress = false;
  37.     
  38.     if ( Enabled() )
  39.         repeat.Schedule();
  40.   }
  41.